<?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use common\components\widgets\Datetimepicker;
Datetimepicker::widget(['timepicker' => 'true','format'=>'Y-m-d H:i']);
?>
    <div class="yx-praise-box zx-min-height">
        <div class="yx-praise-list-box yx-praise-list-box1">
            <?php $form = ActiveForm::begin(['enableClientValidation' => false, 'enableAjaxValidation' => true, 'options' => ['class' => 'form-validate']]); ?>
            <table width="100%" class="table-form">
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['price_name']; ?></th>
                    <td><?= $form->field($model, 'price_name', ['template' => '{input}{error}{hint}'])->textInput(['style' => 'width:180px', 'class' => 'input-text']) ?></td>
                </tr>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['is_activity']; ?></th>
                    <td><?= $form->field($model, 'is_activity', ['template' => '{input}{error}{hint}'])->radioList([1=>'是',0=>'否'], ['style' => 'width:180px']) ?></td>
                </tr>
                <tbody id="activity_box" style="display: <?php if($model->is_activity == 1) { ?> <?php }else {?>none<?php } ?>">
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['activity_name']; ?></th>
                    <td><?= $form->field($model, 'activity_name', ['template' => '{input}{error}{hint}'])->textInput(['style' => 'width:180px', 'class' => 'input-text']) ?></td>
                </tr>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['activity_start_time']; ?></th>
                    <td><?= $form->field($model, 'activity_start_time', ['template' => '{input}{error}{hint}'])->textInput(['style' => 'width:180px', 'class' => 'datetimepicker input-text']) ?></td>
                </tr>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['activity_end_time']; ?></th>
                    <td><?= $form->field($model, 'activity_end_time', ['template' => '{input}{error}{hint}'])->textInput(['style' => 'width:180px', 'class' => 'datetimepicker input-text']) ?></td>
                </tr>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['effective_number']; ?></th>
                    <td><?= $form->field($model, 'effective_number', ['template' => '{input}{error}{hint}'])->textInput(['style' => 'width:180px', 'class' => 'input-text']) ?></td>
                </tr>
                </tbody>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['is_frequency']; ?></th>
                    <td><?= $form->field($model, 'is_frequency', ['template' => '{input}{error}{hint}'])->radioList([1=>'是',0=>'否'], ['style' => 'width:180px']) ?></td>
                </tr>
                <tbody id="frequency_box" style="display: <?php if($model->is_frequency == 0) { ?> <?php }else {?>none<?php } ?>">
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['deadline_type']; ?></th>
                    <td style="display: inline-block;width: 206px"><?= $form->field($model, 'deadline_type', ['template' => '{input}{error}{hint}'])->widget(\kartik\select2\Select2::className(),['data'=>['month'=>'月','year'=>'年'],'options' => ['placeholder' => '请选择']]) ?></td>
                </tr>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['deadline']; ?></th>
                    <td style="display: inline-block;width: 206px"><?= $form->field($model, 'deadline', ['template' => '{input}{error}{hint}'])->widget(\kartik\select2\Select2::className(),['data'=>[1=>1,2=>2,3=>3,4=>4,5=>5,7=>7,8=>8,9=>9,10=>10],'options' => ['placeholder' => '请选择']]) ?></td>
                </tr>
                </tbody>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['type_id']; ?></th>
                    <td style="display: inline-block;width: 206px"><?= $form->field($model, 'type_id', ['template' => '{input}{error}{hint}'])->widget(\kartik\select2\Select2::className(),['data'=>[1=>'益智',2=>'音乐',3=>'形体'],'options' => ['placeholder' => '请选择']]) ?></td>
                </tr>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['lesson']; ?></th>
                    <td><?= $form->field($model, 'lesson', ['template' => '{input}{error}{hint}'])->textInput(['style' => 'width:180px', 'class' => 'input-text']) ?></td>
                </tr>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['distribution_way']; ?></th>
                    <td><?= $form->field($model, 'distribution_way', ['template' => '{input}{error}{hint}'])->radioList([1=>'比例',0=>'固定'], ['style' => 'width:180px']) ?></td>
                </tr>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['subsidy_type']; ?></th>
                    <td><?= $form->field($model, 'subsidy_type', ['template' => '{input}{error}{hint}'])->radioList([1=>'按学生',0=>'按课程'], ['style' => 'width:180px']) ?></td>
                </tr>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['is_scholarship']; ?></th>
                    <td><?= $form->field($model, 'is_scholarship', ['template' => '{input}{error}{hint}'])->radioList([1=>'是',2=>'否'], ['style' => 'width:180px']) ?></td>
                </tr>
                <tr>
                    <th class="zx-goods-table"><?= $model->attributeLabels()['status']; ?></th>
                    <td><?= $form->field($model, 'status', ['template' => '{input}{error}{hint}'])->radioList([1=>'启用',0=>'禁用'], ['style' => 'width:180px']) ?></td>
                </tr>
            </table>
            <div class="zx-button-center">
                <?= Html::submitButton('提交', ['class' => "btn yx-next-step yx-radius5 button_step", 'id' => 'button']) ?>
            </div>
            <?php ActiveForm::end(); ?>
        </div>
    </div>
<?php
$js = <<<JS
    $(document).on('change','input[name="PricePackage[is_activity]"]',function(){
         var vals = $(this).val();
         if(vals === '1'){
             $('#activity_box').css('display','');
         }else {
             $('#activity_box').css('display','none');
         }
    });
    $(document).on('change','input[name="PricePackage[is_frequency]"]',function(){
         var vals = $(this).val();
         if(vals === '0'){
             $('#frequency_box').css('display','');
         }else {
             $('#frequency_box').css('display','none');
         }
    });
JS;
$this->registerJS($js);
?>